package com.eax.ModelLayer;
import java.util.ArrayList;

public class CopyCollectionModel {
	private ArrayList<CopyModel> copyCollection;

	public CopyCollectionModel(){
		copyCollection = new ArrayList<CopyModel>();
	}

	public void addCopy(int serialNumber, int dvdId, String dateOfPurchase, double purchasePrice, String status, Boolean available){
		CopyModel newCopy;
		newCopy = new CopyModel(serialNumber, dvdId, dateOfPurchase, purchasePrice, status, available);
		copyCollection.add(newCopy);
	}

	public void removeCopy(CopyModel copy){
		copyCollection.remove(copy);
	}

	public int getSize(){
		return copyCollection.size();
	}

	public void printAllCopies(){
		for(CopyModel c : copyCollection){
			c.printInfo();
			System.out.println();
		}
	}

	public ArrayList<CopyModel> getAllCopies(){
		return copyCollection;
	}

	public CopyModel getCopyBySerialNumber(int serialNumber){
		CopyModel copy = null;

		for(CopyModel c : copyCollection){
			if(c.getSerialNumber() == serialNumber){
				copy = c;
			}
		}

		return copy;
	}

	public int getHighestSerialNumber(){
		int i = 0;

		for(CopyModel c : copyCollection){
			if(c.getSerialNumber() > i){
				i = c.getSerialNumber();
			}
		}

		return i;
	}

	public void removeAllForDVD(int id){
		for(CopyModel c: copyCollection){
			if(c.getDvdId() == id){
				copyCollection.remove(c);
			}
		}
	}
}